<template>
	<view class="shop-page">
		<view class="info">
			<image :src="shopData.headUrl" mode="" ></image>
			<view class="info-right">
				<view class="mchName">{{shopData.mchName}}</view>
				<view class="levelName">{{shopData.levelName}}</view>
			</view>
		</view>
		<view class="address ">地址：{{shopData.mchAddress}}</view>
		<view class="distance">(距离您：{{distance}}km)</view>
		
		<view class="icons ">
			<view class="icon" @click="call">
				<image src="../../static/img/tel.png" mode=""></image>
				<view class="title">致电商家</view>
			</view>
			<view class="icon" style="margin-left: 30upx;" @click="locate">
				<image src="../../static/img/adress.png" mode=""></image>
				<view class="title">位置导航</view>
			</view>
		</view>
		

	</view>
</template>

<script>
	export default {
		data() {
			return {
				shopData: null,
				mchId: '',
				distance:''
			}
		},
		onLoad(options) {
			console.log("this.shopData: ", this.shopData);
			// this.mchId = options.id
			this.distance = options.distance
			this.mchId = '1422719594473304065'
			this.getShopInfo()
		},

		methods: {
			getShopInfo() {
				let data = {
					id: this.mchId
				}
				this.$request.post(`user/myInfo/${this.mchId}`, data)
					.then(res => {
						console.log(" res:", res)
						this.shopData = res.data.data
					}).catch(err => {
						console.log(" err:", err)
					})
			},
			
			call(){
				uni.makePhoneCall({
					phoneNumber: this.shopData.phone
				});
			},
			
			locate(){
				uni.openLocation({
					latitude: Number(this.shopData.lat),
					longitude: Number(this.shopData.lon),
					scale: 18,
					success: function() {
						console.log('success');
					}
				})
			},
			
			
		}
	}
</script>

<style>
	.shop-page {
		padding: 0 30upx;
		background-color: white;
		height: 100vh;
		
	}

	.shop-page view {
		display: flex;
	}
	.shop-page .info {
		margin-top: 30upx;
		background-color: white;
	}
	.shop-page .info image {
		width: 200upx;
		height: 200upx;
		border-radius: 12upx;
	}
	.shop-page .info-right {
		flex-direction: column;
		margin-left: 15upx;
	}
	.shop-page .info-right .mchName{
		font-size: 30upx;
		font-weight: 700;
		margin-top: 20upx;
	}
	.shop-page .info-right .levelName{
		font-size: 28upx;
		border: 2upx solid #E6A23C;
		border-radius: 6upx;
		color: #E6A23C;
		padding: 4upx 10upx;
		text-align: center;
		margin-top: 15upx;
	}
	
	.shop-page .address{
		font-size: 28upx;
		margin-top: 30upx;
	}
	.shop-page .distance{
		font-size: 28upx;
		color: #777777;
	}
	.shop-page .icons{
		margin-top: 30upx;
	}
	.shop-page .icon{
		flex-direction: column;
		align-items: center;
	}
	.shop-page .icon image{
		width: 60upx;
		height: 60upx;
		border-radius: 12upx;
	}
	.shop-page .icon .title{
		margin-top: 20upx;
		font-size: 24upx;
	}
	.divider-line{
		width: 100%;
		height: 10upx;
		background-color: #DDDDDD;
	}
</style>
